package com.topdt.jbpm.utils;

import java.util.ArrayList;
import java.util.List;

import com.topdt.jbpm.form.query.FieldType;
import com.topdt.jbpm.form.query.Option;
import com.topdt.jbpm.form.query.Param;
import com.topdt.jbpm.model.OptionImpl;
import com.topdt.jbpm.model.ParamImpl;


public class SelectConstant {
	public static final String DICTIONARY_CODE = "_workflow";//--与工作流有关的字典
	public static final String DICTIONARY_MORE = "_more";//--工作流中多选的字典  _workflow_more
	public static final String DICTIONARY_SINGLE = "_single";//--工作流中单选的字典  
	//--树状下拉框参数
	private static final String[][] TREESELECT = new String[][]{{"org","org","组织机构"}};
	//--系统变量参数
	private static final String[][] SYSTEMSELECT = new String[][]{{"1","currentUser","当前用户"},{"2","currentTime","当前时间"}};
	private static final String[][] FIELDTYPES = new String[][] { { "text", "单行文本","none" },{ "textarea", "多行文本","none" }, { "number", "数字","none" },
		{ "email", "邮箱","none" }, { "date", "日期","none" }, { "datetime", "日期时间","none" }, { "time", "时间","none" }, { "mobile", "手机号","none" },
		{"phone","电话号码","none"},{"tree","树状","tree"},{"select","下拉菜单","single"},{"radio","单选框","single"},{"checkbox","复选框","more"},{"richTextEditer","富文本框","none"},{"url","URL","none"},{"systemVar","系统变量","system"}};
	public static String[][] getFieldTypes(){
		return FIELDTYPES;
	}
	public static List<FieldType> listFieldType(){
		List<FieldType> list = new ArrayList<FieldType>();
		for(String[] type : FIELDTYPES){
			FieldType fieldType = new FieldType();
			fieldType.setKey(type[0]);
			fieldType.setName(type[1]);
			fieldType.setParam(type[2]);
			list.add(fieldType);
		}
		return list;
	}
	public static FieldType getFiledTypeByKey(String key){
		for(String[] type : FIELDTYPES){
			if(key.equals(type[0])){
				FieldType fieldType = new FieldType();
				fieldType.setKey(type[0]);
				fieldType.setName(type[1]);
				fieldType.setParam(type[2]);
				return fieldType;
			}
		}
		return null;
	} 
	/**
    * 
   * @author _zili
   * @Description:获取树状所对应的下拉框数据
   * @date 2015年4月1日 下午5:35:46
    */
	public static List<Param> getTreeSelect(){
		List<Param> list = new ArrayList<Param>();
		for(String[] p:TREESELECT){
			ParamImpl param = new ParamImpl();
			param.setId(p[0]);
			param.setName(p[2]);
			list.add(param);
		}
		return list;
	}
	/**
	 * 
	* @author _zili
	* @Description:获取系统所对应的下拉框数据
	* @date 2015年4月1日 下午5:37:35
	 */
	public static List<Param> getSystemSelect(){
		List<Param> list = new ArrayList<Param>();
		for(String[] p:SYSTEMSELECT){
			ParamImpl param = new ParamImpl();
			param.setId(p[0]);
			param.setName(p[2]);
			list.add(param);
		}
		return list;
	}
	public static List<Param> listAll(){
		List<Param> params = new ArrayList<Param>();
		for(String[] item :SYSTEMSELECT){
			ParamImpl paramImpl = new ParamImpl();
			paramImpl.setId(item[0]);
			paramImpl.setName(item[2]);
			params.add(paramImpl);
		}
		return params;
	}
	public static Option getOptionByParamId(String id){
		OptionImpl option = new OptionImpl();
		for(String[] item :SYSTEMSELECT){
			if(id.equals(item[0])){
				option.setId(item[0]);
				option.setName(item[2]);
				option.setValue(item[1]);
			}
		}
		return option;
	}
}
